package com.itlaoqi.rabbitmq.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class RabbitUtils {
    private static ConnectionFactory connectionFactory = new ConnectionFactory();

    static {
        connectionFactory.setHost("192.168.10.10");//
        connectionFactory.setPort(5672);//是rabbitmq的默认端口号
        connectionFactory.setUsername("itlaoqi");
        connectionFactory.setPassword("123456");
        connectionFactory.setVirtualHost("/test");
    }

    public static Connection getConnection(){
        Connection conn = null;
        try {
            return connectionFactory.newConnection();
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
